﻿package mortal.game.view.chat.chatPanel
{
    import __AS3__.vec.*;
    import com.mui.containers.*;
    import com.mui.containers.globalVariable.*;
    import flash.display.*;

    public class ChatBox extends GBox
    {
        private var _itemVector:Vector.<ChatNotes>;
        private var _maxItem:int;
        private var _lastChatNotes:ChatNotes = null;

        public function ChatBox(param1:int = 30)
        {
            this._maxItem = param1;
            this._itemVector = new Vector.<ChatNotes>;
            this.mouseEnabled = false;
            super.direction = GBoxDirection.VERTICAL;
            super.verticalGap = 0;
            return;
        }// end function

        public function addChatNotes(param1:ChatNotes) : void
        {
            this.addChild(param1);
            this.validateNow();
            this.updateDisplayList();
            this._itemVector.push(param1);
            if (this._itemVector.length > this._maxItem)
            {
                param1 = this._itemVector.shift();
                this.removeChild(param1);
                param1.dispose();
            }
            this._lastChatNotes = param1;
            this.validateNow();
            this.updateDisplayList();
            return;
        }// end function

        public function get currentLength() : int
        {
            return this._itemVector.length;
        }// end function

        public function isMaxLength() : Boolean
        {
            return this._itemVector.length == this._maxItem;
        }// end function

        public function getChatNotesAtIndex(param1:int) : ChatNotes
        {
            return this._itemVector[param1];
        }// end function

        override public function get height() : Number
        {
            var _loc_4:DisplayObject = null;
            var _loc_5:int = 0;
            var _loc_1:Number = 0;
            var _loc_2:int = 0;
            var _loc_3:* = numChildren;
            while (_loc_2 < _loc_3)
            {
                
                _loc_4 = getChildAt(_loc_2) as DisplayObject;
                _loc_1 = _loc_1 + _loc_4.height;
                _loc_2++;
            }
            return _loc_1 + verticalGap * (this._itemVector.length - 1) + 5;
        }// end function

        public function reset() : void
        {
            var _loc_1:int = 0;
            _loc_1 = 0;
            while (_loc_1 < this._itemVector.length)
            {
                
                this.removeChild(this._itemVector[_loc_1]);
                this._itemVector[_loc_1].dispose();
                _loc_1++;
            }
            this._itemVector = new Vector.<ChatNotes>;
            return;
        }// end function

    }
}
